package studychinese.utils;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * Created by String on 2015/10/10.
 */
public class VerifyUtils {
    //判断是否为手机号
    public static boolean isMobileNO(String mobiles) {
        Pattern p = Pattern.compile("^(0|86|17951)?(13[0-9]|15[012356789]|17[0-9]|18[0-9]|14[579])[0-9]{8}$");
        Matcher m = p.matcher(mobiles);
        return m.matches();
    }

    //判断密码格式是否正确
    public static boolean isPwdNO(String pwd) {
        Pattern p = Pattern.compile("^[~!@#$%^&*()_+0-9A-Za-z]{6,}$");
        Matcher m = p.matcher(pwd);
        return m.matches();
    }
    //判断是否为邮箱

    public static boolean isEmailNO(String emails) {
        Pattern p = Pattern.compile("^[\\w_-]+@[\\w_-]+[\\.a-zA-Z]+[^\\.]$");
        Matcher m = p.matcher(emails);
        return m.matches();
    }
    public static boolean isEmail(String string) {
        if (string == null)
            return false;
        String regEx1 = "^([a-z0-9A-Z]+[-|\\.]?)+[a-z0-9A-Z]@([a-z0-9A-Z]+(-[a-z0-9A-Z]+)?\\.)+[a-zA-Z]{2,}$";
        Pattern p;
        Matcher m;
        p = Pattern.compile(regEx1);
        m = p.matcher(string);
        if (m.matches())
            return true;
        else
            return false;
    }
    /**
     * 判断是否为身份证号
     *
     * @param idNumber
     * @return
     */
    public static boolean isIdNumber(String idNumber) {
        Pattern p = Pattern.compile("(^\\d{18}$)|(^\\d{15}$)");
        Matcher m = p.matcher(idNumber);
        return m.matches();
    }
}
